{include file="Public:header" /}
<link href="__PUBLIC__/Admin/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />

<style>
	.table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th{
		padding:0px 5px;
		text-align: center; 
		vertical-align: middle!important;
	}
</style>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-title">
						<h5>订单列表</h5>
						<a href="__MODULE__/{$Think.CONTROLLER_NAME}/{$Think.ACTION_NAME}" style="margin-top: -6px;" class="btn btn-primary pull-right"><i class="fa fa-refresh"></i> 刷新</a>
					</div>
					<div class="ibox-content">
						<div class="row">
						<div class="col-sm-2">
<!--							<a href="__URL__/addOrder?act=add" class="btn btn-primary">
								<span class="fa fa-plus"></span>
								添加订单
							</a>-->
						</div>
						<form class="form-inline" action="__URL__/orderForm" method="get">
								<div class="col-sm-10">
		                                <div class="input-group col-sm-3  pull-right">
			                                    <input type="text" name="position" placeholder="主题名称" class="input-sm form-control" value="{$data['position']}"> 
			                                    <span class="input-group-btn">
			                                      <button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
			                                    </span>
		                                </div>
										
										<div class="input-group col-sm-2 pull-right">
											  <input type="text" name="order_form" placeholder="订单编号" class="input-sm form-control select_no_border"  value="{$data['order_form']}"> 
                                   		</div>
                                   		
                                   		<div class="input-group col-sm-2 pull-right select_width">
											 <select name="pay" class="input-sm form-control select_no_border">
											 	<option value="">支付状态</option>
		                                        <option value="1" {if condition="$data['pay'] eq 1"}selected{/if}>未支付</option>
		                                        <option value="2" {if condition="$data['pay'] eq 2"}selected{/if}>已支付</option>
		                                    </select>
                                   		</div>
                                   		
                                   		 <div class="input-group col-sm-2 pull-right select_width">
											 <select name="order_status" class="input-sm form-control select_no_border">
											 	<option value="">订单状态</option>
		                                        <option value="1" {if condition="$data['pay'] eq 1"}selected{/if}>待付款  </option>
		                                        <option value="2" {if condition="$data['pay'] eq 2"}selected{/if}>待参与 </option>
		                                        <option value="3" {if condition="$data['pay'] eq 3"}selected{/if}>已完成 </option>
		                                        <option value="4" {if condition="$data['pay'] eq 4"}selected{/if}>已取消 </option>
		                                    </select>
                                   		</div>
                                   		
                                   		<div class="input-group col-sm-3 pull-right">
                                   		<span class="input-group-addon">
						                    <span class="fa fa-calendar"></span>
						                </span>
						                <input type="text" name="add_time" value="" placeholder="2017-06-14 - 2017-07-14" class="input-sm form-control select_no_border" id="start_time">
						                <!-- <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span> -->
						                
						            </div>
	                                
	                            </div>
	                     </form>  
						</div>
						
						<br />
						
						<div class="table-responsive">
						<form action="__URL__/operate" method="post" id="operate_form">	
							<table class="table table-bordered table-hover"
								id="categoryTable">
								<thead>
									<tr class="active">
									<th><input onclick="choosebox(this)" type="checkbox" /></th>
									<th height="40">编号</th>
									<th>订单编号</th>
                                                                        <th>姓名</th>
                                                                        <th>联系方式</th>
                                                                        <th>邮箱</th>
									<th style="width:150px;">预约主题</th>
                                                                        <th>专家姓名</th>
									<th>金额</th>
									<th>订单状态</th>
									<th>支付状态</th>
                                                                        <th>预约时间</th>
									<th width="10%">下单时间</th>
									<th width="100">操作</th>
									</tr>
								</thead>
								<tbody>
									{foreach name="orderList" item="orderList"}
									<tr>
									<td><input type="checkbox" name="order_id[]" value="{$order['id']}" /></td>
									<td>{$orderList['id']}</td>
                                                                        <td>{$orderList['order_form']}</td>
                                                                        <td>{$orderList['username']}</td>
                                                                        <td>{$orderList['phone']}</td>
									<td>{$orderList['email']}</td>
									<td><p title="{$orderList['title']}" style="width:150px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">{$orderList['position']}</p></td>
									<td>{$orderList['name']}</td>
									<td>{$orderList['pay']}</td>
									<td>
                                                                            {switch name="orderList['order_status']"}
										    {case value="1"}待付款 {/case}
										    {case value="2"}待参与{/case}
										    {case value="3"}已完成{/case}
										    {case value="4"}已取消{/case}
										 {/switch}
									</td>
                                                                        
									<td>
										 {switch name="orderList['status']"}
										    {case value="1"}未支付 {/case}
										    {case value="2"}已支付{/case}
										 {/switch}
									</td>
                                                                        <td>{$orderList['select_time']}</td>
									<td>
										 {$orderList['create_time']|date="Y-m-d",###}
									</td>
										<td class="center">
										<!-- <button class="btn btn-white btn-sm" data-toggle="tooltip" data-placement="top" title="标为垃圾邮件"><i class="fa fa-trash-o"></i>
                       					 </button> -->
											 <div class="dropdown">
												<button class="btn btn-primary dropdown-toggle"
													type="button" id="dropdownMenu1" data-toggle="dropdown"
													aria-haspopup="true" aria-expanded="true">
													操作
													<span class="caret"></span>
												</button>
												<ul class="dropdown-menu" style="min-width: 90px;" aria-labelledby="dropdownMenu1">
													<li>
														<a role="button" class="btn btn-primary"
															style="margin-bottom: 0px;" 
															href="__URL__/addOrder?id={$orderList['id']}&act=edit">
															<span class="fa fa-edit"></span>
															修改
														</a>
													</li>
													<li>
														<a role="button" class="btn btn-danger"
															style="margin-bottom: 0px;"
															onclick="deleteOrder(this,{$orderList['id']})" href="javascript:void(0);">
															<span class="fa fa-trash-o"></span>
															删除
														</a>
													</li>
												</ul>
											</div> 
										</td>
									</tr>
									{/foreach}
								</tbody>
							</table>
							<div class="col-sm-12" style="padding:0px;">
								<div class="col-sm-4" style="padding-left:0px;"> 
									<select id="operate" name="operate" class="input-sm form-control pull-left" style="width:100px;margin-right: 5px;">
													 	<option value="0">选择操作</option>
													 	<option value="order_status_1">待付款  </option>
													 	<option value="order_status_2">待参与 </option>
													 	<option value="order_status_3">已完成</option>
													 	<option value="order_status_4">已取消</option>
				                                        <option value="payment_status_1">未支付</option>
				                                        <option value="payment_status_2">已支付</option>
				                                        <option value="del">删除</option>
				                     </select>
				                     <button tpye="button"  class="btn btn-primary pull-left"> 确认</button>
			                    </div>
								<div class="col-sm-8" style="padding:0px;">
								  <ul class="pagination  pull-right">
								    {$page}
								  </ul>
								</div>
							</div>	
						</form>
						</div>
						
					</div>
				</div>
			</div>
		</div>
	</div>
<script>
function choosebox(o){
    var vt = $(o).is(':checked');
    if(vt){
        $('input[type=checkbox]').prop('checked',vt);
    }else{
        $('input[type=checkbox]').removeAttr('checked');
    }
}
</script>

{include file="Public:footer" /}
<script src="__PUBLIC__/Admin/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/Admin/daterangepicker/daterangepicker.js" type="text/javascript"></script>
	<script>

//修改菜单
function editGroup(obj){
	var group_id = $(obj).attr('group_id');
	var group_title = $(obj).attr('group_title');
	$('#myModal').modal('show');
	$("#defaultForm").attr('action','__URL__/editUserGroup?id='+group_id);
	$("input[name='title']").val(group_title);
}

// window.onload=setTotal();	

//删除
function deleteOrder(obj, id){
	layer.confirm('确定要删除数据吗',{btn:['确认','取消'], icon:3, closeBtn: 2 },function(index){
		$.ajax({
			url : '__URL__/deleteOrder',
			data : {'id':id},
			type : 'get',
			dataType : 'json',
			async : false,   //取消同步，执行完之后再往下执行
			success : function(data){
				if(data.status == 1){				
					layer.msg(''+data.message+'',{icon:2,time:1000});
					$(obj).parent('li').parent('ul').parent('div').parent('td').parent('tr').remove();
				}else if(data.status == 2){
					layer.msg(''+data.message+'',{icon:1,time:1000});
				}
			}
		});
	});	
}
</script>
<script>
$(document).ready(function() {
	$('#start_time').daterangepicker({
		format:"YYYY-MM-DD",
		singleDatePicker: false,
		showDropdowns: true,
		minDate:'2016-01-01',
		maxDate:'2030-01-01',
		startDate:'2016-01-01',
		endDate:'2017-01-01',
        showWeekNumbers: true,
        timePicker: false,
        timePickerIncrement: 1,
        timePicker12Hour: true,
        ranges: {
           '今天': [moment(), moment()],
           '昨天': [moment().subtract('days', 1), moment().subtract('days', 1)],
           '最近7天': [moment().subtract('days', 6), moment()],
           '最近30天': [moment().subtract('days', 29), moment()],
           '上一个月': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')]
        },
        opens: 'right',
        buttonClasses: ['btn btn-default'],
        applyClass: 'btn-small btn-primary',
        cancelClass: 'btn-small',
	    locale : {
            applyLabel : '确定',
            cancelLabel : '取消',
            fromLabel : '起始时间',
            toLabel : '结束时间',
            customRangeLabel : '自定义',
            daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
            monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
            firstDay : 1
        }
	});
	
});
</script>
<script>
    //操作
    $('#operate_form').submit(function(){
    	var op_type = $("select[name='operate']").val();
        if(op_type == 0){
    		layer.msg('请选择操作', {time: 1000});   //alert('请选择操作');
            return false;
        }
        var selected = $("input[name='order_id[]']:checked");
        if(selected.length < 1){
    		layer.msg('请选择记录', {time: 1000}); //            alert('请选择项目');
    		return false;
        }
        
    });
</script>
</body>
</html>
